// 聊天记录 数据
import { createSlice } from "@reduxjs/toolkit";

export const chatRecords = createSlice({
  name: "chatRecords",
  initialState: {
    // 数据
    cList: [],
  },
  reducers: {
    cListSet: (state, action) => {
      state.cList = action.payload;
      console.log(action.payload);
    },
    // 搜索
    searchSet: (state, action) => {
      state.cList = state.cList.filter((item, index) => {
        return item.name.includes(action.payload);
      });
    },
  },
});
// 每个 case reducer 函数会生成对应的 Action creators
export const { cListSet, searchSet } = chatRecords.actions;

export default chatRecords.reducer;
